package com.yf.course.modules.course.dto.ext;

import com.yf.course.modules.course.dto.CourseDTO;
import com.yf.course.modules.course.dto.response.CourseLiveRespDTO;
import com.yf.course.modules.course.dto.CourseRefPointDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
* <p>
* 课程信息数据传输类
* </p>
*
* @author 聪明笨狗
* @since 2020-12-17 11:28
*/
@Data
@ApiModel(value="课程信息", description="课程信息")
public class CourseDetailExtDTO extends CourseDTO {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "课程部门列表", required=true)
    private List<String> deptCodes;

    @ApiModelProperty(value = "目录列表", required=true)
    private List<CourseRefDirExtDTO> dirList;

    @ApiModelProperty(value = "知识点列表", required=true)
    private List<CourseRefPointDTO> pointList;

    @ApiModelProperty(value = "直播列表", required=true)
    private List<CourseLiveRespDTO> liveList;

    @ApiModelProperty(value = "是否购买", required=true)
    private Boolean isBuy;

    @ApiModelProperty(value = "当日学习时长", required=true)
    private Integer learnMin;

    @ApiModelProperty(value = "是否学完", required=true)
    private Boolean finished;

    @ApiModelProperty(value = "讲稿", required=true)
    private String speechText;

    /**
     * 获取文件数量
     * @return
     */
    public int getFileCount(){

        int count = 0;

        if(!CollectionUtils.isEmpty(dirList)){
            for(CourseRefDirExtDTO item: dirList){
                List<CourseRefFileExtDTO> files = item.getFileList();
                if(!CollectionUtils.isEmpty(files)){
                    count += files.size();
                }
            }
        }

        return count;
    }

}
